package GUI;
//
//import Negocios.ControlProviders;
//import Utilidades.Validaciones;
import java.awt.Color;
import javax.swing.JOptionPane;

/**
 *
 * @author lightemp
 */
public class RegistroProveedor extends javax.swing.JInternalFrame {

    private String mensajeVal = null;

    public RegistroProveedor() {
        initComponents();
        this.getContentPane().setBackground(Color.red);
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jpContenedor = new javax.swing.JPanel();
        jpInfoProveedor = new javax.swing.JPanel();
        jtfNombre = new javax.swing.JTextField();
        jtfDireccion = new javax.swing.JTextField();
        jtfTelefono = new javax.swing.JTextField();
        jtfEmail = new javax.swing.JTextField();
        jllIconoProveedor = new javax.swing.JLabel();
        jbGuardar = new javax.swing.JButton();
        jbCancelar = new javax.swing.JButton();
        jlLeyenda = new javax.swing.JLabel();

        setClosable(true);
        setIconifiable(true);
        setResizable(true);
        setTitle("OM Maribetza - Registro de Proveedores");
        setFrameIcon(new javax.swing.ImageIcon(getClass().getResource("/Iconos/SIPE-ICON.png"))); // NOI18N

        jpContenedor.setBackground(new java.awt.Color(255, 0, 0));

        jpInfoProveedor.setBackground(new java.awt.Color(255, 255, 255));
        jpInfoProveedor.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.LOWERED));

        jtfNombre.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
        jtfNombre.setToolTipText("Escribe el nombre del provvedor");
        jtfNombre.setBorder(javax.swing.BorderFactory.createTitledBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 2, true), "Nombre:", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 0, 12))); // NOI18N

        jtfDireccion.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
        jtfDireccion.setToolTipText("Escribe la dirección del proveedor");
        jtfDireccion.setBorder(javax.swing.BorderFactory.createTitledBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 2, true), "Dirección:", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 0, 12))); // NOI18N

        jtfTelefono.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
        jtfTelefono.setToolTipText("Aqui va el telefono del proveedor");
        jtfTelefono.setBorder(javax.swing.BorderFactory.createTitledBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 2, true), "Teléfono:", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 0, 12))); // NOI18N

        jtfEmail.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
        jtfEmail.setToolTipText("Es el campo para el correo electrónico del proveedor");
        jtfEmail.setBorder(javax.swing.BorderFactory.createTitledBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 2, true), "Email:", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 0, 12))); // NOI18N

        jllIconoProveedor.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Iconos/provider.png"))); // NOI18N

        jbGuardar.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        jbGuardar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Iconos/save.png"))); // NOI18N
        jbGuardar.setText("Guardar");
        jbGuardar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbGuardarActionPerformed(evt);
            }
        });

        jbCancelar.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        jbCancelar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Iconos/Cancel.png"))); // NOI18N
        jbCancelar.setText("Cancelar");
        jbCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbCancelarActionPerformed(evt);
            }
        });

        jlLeyenda.setBackground(new java.awt.Color(255, 255, 255));
        jlLeyenda.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
        jlLeyenda.setText("Esta ventana permite agregar un nuevo proveedor a tu lista de proveedores.");
        jlLeyenda.setOpaque(true);

        javax.swing.GroupLayout jpInfoProveedorLayout = new javax.swing.GroupLayout(jpInfoProveedor);
        jpInfoProveedor.setLayout(jpInfoProveedorLayout);
        jpInfoProveedorLayout.setHorizontalGroup(
            jpInfoProveedorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpInfoProveedorLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jllIconoProveedor)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jpInfoProveedorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jtfEmail)
                    .addComponent(jtfTelefono)
                    .addComponent(jtfDireccion)
                    .addComponent(jtfNombre, javax.swing.GroupLayout.DEFAULT_SIZE, 283, Short.MAX_VALUE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jpInfoProveedorLayout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jbGuardar)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jbCancelar, javax.swing.GroupLayout.PREFERRED_SIZE, 127, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
            .addComponent(jlLeyenda, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 435, Short.MAX_VALUE)
        );

        jpInfoProveedorLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jbCancelar, jbGuardar});

        jpInfoProveedorLayout.setVerticalGroup(
            jpInfoProveedorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpInfoProveedorLayout.createSequentialGroup()
                .addComponent(jlLeyenda)
                .addGap(23, 23, 23)
                .addGroup(jpInfoProveedorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jllIconoProveedor, javax.swing.GroupLayout.PREFERRED_SIZE, 130, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jpInfoProveedorLayout.createSequentialGroup()
                        .addComponent(jtfNombre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jtfDireccion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jtfTelefono, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jtfEmail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(18, 18, 18)
                .addGroup(jpInfoProveedorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jbCancelar, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jbGuardar, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jpContenedorLayout = new javax.swing.GroupLayout(jpContenedor);
        jpContenedor.setLayout(jpContenedorLayout);
        jpContenedorLayout.setHorizontalGroup(
            jpContenedorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpContenedorLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jpInfoProveedor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jpContenedorLayout.setVerticalGroup(
            jpContenedorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jpContenedorLayout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jpInfoProveedor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jpContenedor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jpContenedor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

private void jbCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbCancelarActionPerformed
    this.dispose();// TODO add your handling code here:
}//GEN-LAST:event_jbCancelarActionPerformed
    public void cleanFields() {
        jtfNombre.setText("");
        jtfDireccion.setText("");
        jtfTelefono.setText("");
        jtfEmail.setText("");
    }

//    public boolean validaciones() {
////        Validaciones val = new Validaciones();
//        boolean valida = true;
//        if (val.isEmpty(jtfNombre)) {
//            valida = false;
//            mensajeVal = "El campo -Nombre del proveedor- esta vacio";
//        } else if (val.isEmpty(jtfDireccion)) {
//            valida = false;
//            mensajeVal = "El campo -Direccion- esta vacio";
//        } else if (val.isEmpty(jtfTelefono)) {
//            valida = false;
//            mensajeVal = "El campo -Telefono- esta vacio";
//        } else if (val.isEmpty(jtfEmail)) {
//            valida = false;
//            mensajeVal = "El campo -Email- esta vacio";
//        } else if (val.isNumeric(jtfTelefono) == true) {//Validacion de numeros
//            mensajeVal = "El campo -Telefono- no esta bien escrito o contiene letras";
//            valida = false;
//        } else if (val.isEmail(jtfEmail.getText()) == false) {
//            mensajeVal = "El campo -Email- no esta bien escrito";
//            valida = false;
//        }
//        return valida;
//    }
    private void jbGuardarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbGuardarActionPerformed
//        ControlProviders proveedor = new ControlProviders();
//        if (validaciones()) {
//            try {
//                //Comprobar si el nombre del proveedor que pretendemos guardar
//                //esta libre
//                if (proveedor.providerExist(jtfNombre.getText())) {
//                    //no esta libre
//                    JOptionPane.showMessageDialog(this, "Ya existe un proveedor con el nombre '" + jtfNombre.getText() + "'."
//                            + "\n" + "Cambie el nombre para poder agregar una nueva categoria.", "Ya existe este proveedor",
//                            0);
//                    jtfNombre.requestFocus();
//                    jtfNombre.selectAll();
//                } else {
//                    //esta libre
//                    proveedor.add(
//                            jtfNombre.getText(),
//                            jtfDireccion.getText(),
//                            jtfTelefono.getText(),
//                            jtfEmail.getText());
//                    JOptionPane.showMessageDialog(this, "ProveedorGUI guardado con exito.",
//                            "ProveedorGUI guardado.", 1);
//                    //Limpiando campos de texto
//                    cleanFields();
//                }
//            } catch (Exception e) {
//                JOptionPane.showMessageDialog(this, "Ha ocurrido un error al guardar: "
//                        + "\n" + e, "Error al guardar.", 0);
//            }
//        } else {
//            JOptionPane.showMessageDialog(this, mensajeVal);
//        }

    }//GEN-LAST:event_jbGuardarActionPerformed
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jbCancelar;
    private javax.swing.JButton jbGuardar;
    private javax.swing.JLabel jlLeyenda;
    private javax.swing.JLabel jllIconoProveedor;
    private javax.swing.JPanel jpContenedor;
    private javax.swing.JPanel jpInfoProveedor;
    private javax.swing.JTextField jtfDireccion;
    private javax.swing.JTextField jtfEmail;
    private javax.swing.JTextField jtfNombre;
    private javax.swing.JTextField jtfTelefono;
    // End of variables declaration//GEN-END:variables
}
